package com.itheima.chapter03.controller;

import com.itheima.chapter03.domain.Comment;
import com.itheima.chapter03.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("/comment")
    public AjaxResult insertComment(@RequestBody Comment comment) {
        int ret = commentService.insertComment(comment);
        if (ret > 0) {
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
    }
}
